<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list id-key="id" ref="list" unit="提单" :disabled="disabled" :show-query="showQuery" show-checkbox
      :query-params="queryParams" expand-query page @get-data="onGetData" :data="data" :total="total" custom-get-data>
      <template #toolbar-left>
        <slot name="toolbar-left"></slot>
      </template>
      <template #query>
        <div>
          <el-form-item label="提单号">
            <el-input v-model.trim="queryParams.no" placeholder="提单号" clearable></el-input>
          </el-form-item>
          <el-form-item label="运单号">
            <el-input v-model.trim="queryParams.shipmentNo" placeholder="运单号" clearable></el-input>
          </el-form-item>
          <el-form-item label="提单类型">
            <el-select v-model="queryParams.types" clearable multiple collapse-tags>
              <el-option label="HBL" :value="1"></el-option>
              <el-option label="MBL" :value="0"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="放单类型">
            <el-select v-model="queryParams.releaseTypes" clearable multiple collapse-tags>
              <el-option label="新增蓝票" :value="1"></el-option>
              <el-option label="冲红红票" :value="3"></el-option>
              <el-option label="作废票" :value="2"></el-option>
              <el-option label="开票失败" :value="6"></el-option>
            </el-select>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="状态">
            <el-select v-model="queryParams.states" clearable multiple collapse-tags>
              <el-option label="待放" :value="1"></el-option>
              <el-option label="已放" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="提单ID">
            <el-input v-model="queryParams.idString" placeholder="ID，以,或空格分隔" clearable
              style="width:800px;max-width:none">
            </el-input>
          </el-form-item>
        </div>
      </template>
      <template #column>
        <el-table-column prop="no" min-width="180" label="提单号" />
        <el-table-column prop="typeName" width="100" label="提单类型" />
        <el-table-column prop="stateName" width="100" label="状态" />
        <el-table-column prop="releaseTypeName" width="100" label="放单类型" />
        <el-table-column prop="shipmentNo" width="180" label="运单号" />
        <el-table-column prop="creationTime" width="120" label="创建时间" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.creationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="updateTime" label="最近更新时间" width="120" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.updateTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
  </div>
</template>
<script>

import list from "@/components/common/list";
import api from "@/api/fam/releaseOrder";
export default {
  components: {
    list
  },
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    showQuery: {
      type: Boolean,
      default: true
    },
    showCheckbox: {
      type: Boolean,
      default: false
    },
    inDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      //查询条件字段
      queryParams: {
      },
      data: [],
      total: 0
    };
  },
  methods: {
    onGetData(params) {
      this.$refs.list.loading(true);
      api.getPageList(params).then(res => {
        if (res.code != 0) {
          return;
        }
        this.data = res.data.list;
        this.total = res.data.total;
        this.$refs.list.loading(false);
      })
    },
    getCheckedRows() {
      return this.$refs.list.getCheckedRows();
    },
    reload() {
      this.$refs.list.reload();
    }
  },
};
</script>